import SwiftUI
import SPGlassKit

public struct GlassTextAreaExample: GlassExample {
    public static let componentID = "glass-text-area"
    @State private var notes = ""
    @State private var bio = "Hiking 🥾, bread 🍞 and old maps 🗺️."
    @State private var feedback = "Too short"

    public init() {}

    public var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: 20) {
                GlassTextArea("Notes", text: $notes, placeholder: "Anything the team should know before the visit", helper: "Visible to your team only.")

                GlassTextArea("Short bio", text: $bio, limit: 40)

                GlassTextArea(
                    "Feedback",
                    text: $feedback,
                    showsCounter: true,
                    minHeight: 72,
                    errorMessage: feedback.count < 20 ? "Please write at least 20 characters." : nil
                )

                GlassTextArea("Archived comment", text: .constant("This comment can no longer be edited."))
                    .disabled(true)
            }
            .padding()
        }
    }
}

#Preview("GlassTextArea") { GlassTextAreaExample().glassTheme(.solar) }
